<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>k12后台管理</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.0/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.1.5/vue.global.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.0/js/bootstrap.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

    <script src="js/echarts.min.js"></script>
    <script src="js/checkLogin.js"></script>
    <style>
        .menu {
            cursor: pointer;
        }
    </style>
</head>

<body class="container">

    <div class="row">
        <div class="page-header">
            <h3>K12 学员测评系统 <small>全面测评，打造完美</small></h3>
        </div>
    </div>

    <div class="row">
        <div class="col-md-2 panel panel-default">

            <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                    <h4 class="panel-title">
                        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne"
                            aria-expanded="true" aria-controls="collapseOne">
                            模板管理
                        </a>
                    </h4>
                </div>
                <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                    <div class="panel-body">
                        <ul class="list-group">
                            <li class="list-group-item menu" url="template-list.html">模板列表</li>
                            <li class="list-group-item menu" url="template-add.html">新增模版</li>
                            <li class="list-group-item menu" url="template-import.html">导入模板</li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                    <h4 class="panel-title">
                        <a class="collapsed" role="button" data-toggle="collapse " data-parent="#accordion"
                            href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                            测评管理
                        </a>
                    </h4>
                </div>
                <div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo">
                    <div class="panel-body">
                        <ul class="list-group">
                            <li class="list-group-item menu" url="test-score-list.html">测评成绩列表</li>
                            <li class="list-group-item menu" url="test-score.html">新增测评成绩</li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingThree">
                    <h4 class="panel-title">
                        <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion"
                            href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
                            用户管理
                        </a>
                    </h4>
                </div>
                <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
                    <div class="panel-body">
                        <ul class="list-group">
                            <li class="list-group-item menu" url="user-list.html">用户列表</li>
                            <li class="list-group-item menu" url="user-add.html">新增用户</li>
                            <li class="list-group-item menu" url="student-list.html">学员列表</li>
                            <li class="list-group-item menu" url="student-add.html">新增学员</li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingFour">
                    <h4 class="panel-title">
                        <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion"
                            href="#collapseFour" aria-expanded="false" aria-controls="collapseFour">
                            系统管理
                        </a>
                    </h4>
                </div>
                <div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
                    <div class="panel-body">
                        <ul class="list-group">
                            <li class="list-group-item menu" url="">修改密码</li>
                            <li class="list-group-item menu">退出系统</li>
                        </ul>
                    </div>
                </div>
            </div>

        </div>

        <div class="col-md-10 panel panel-default">
            <div>

                <!-- Nav tabs  -->
                <ul class="nav nav-tabs" role="tablist" id="tableTitles">
                    <!-- active 控制显示 -->
                    <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab"
                            data-toggle="tab">Home</a></li>
                </ul>

                <!-- Tab panes  -->
                <div class="tab-content" id="tableContents">
                    <!-- active 控制显示 -->
                    <div role="tabpanel" class="tab-pane active" id="home">
                        <h1> 欢迎使用 </h1>
                    </div>


                </div>

            </div>
        </div>

    </div>

    <div class="row">
        <div class="panel panel-default">
            <div class="panel-body" style="text-align: center;">
                版权所有@起点编程0711
            </div>
        </div>

    </div>

    <script>

        $(document).ready(function () {
            $('.menu').click(function () {
                // $(this) jquery调用this
                let url = $(this).attr("url");
                let name = $(this).text();

                showOrCheckTab(name, url)

            });
        });
        //  添加或者选择选项卡
        function showOrCheckTab(name, url) {
            let isActive = false;
            let titles = $("#tableTitles").find("li");
            for (let x = 0; x < titles.length; x++) {
                // 查找遍历 每一个名字  遍历每一个
                // $(数组)
                if (name == $(titles[x]).text()) {
                    //存在就点击
                    $(titles[x]).find("a").click();
                    isActive = true;
                } else {
                    //移除 所有的 active 
                    $(titles[x]).removeClass("active");
                }
            }

            if (!isActive) {
                let id = "id_" + Math.floor((Math.random() * 100));
                //添加新的
                let titleLi = `<li role="presentation" class="active"><a href="#${id}" aria-controls="${id}" role="tab" data-toggle="tab">${name}</a></li>`;
                $("#tableTitles").append(titleLi);
                //内容 移除所有的
                $("#tableContents > div").removeClass("active");

                let contentDiv = `<div role="tabpanel" class="tab-pane active" id="${id}"></div>`;
                //添加 内容
                $("#tableContents").append(contentDiv);
                //
                $("#" + id).load(url);
            }
        }
    </script>

    <div id="win-msg" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
        aria-labelledby="mySmallModalLabel" style="display: none;">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="mySmallModalLabel">提示</h4>
                </div>
                <div class="modal-body">
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>


    <script>
        function showMsg(msg, title) {
            if (title) {
                $("#win-msg").find(".modal-title").text(title);
            }
            if (msg) {
                $("#win-msg").find(".modal-body").text(msg);
            }
            $("#win-msg").modal('show');
        }
    </script>

</body>

</html>